package hr.dario.android;

import android.app.Activity;
import android.os.Bundle;
import android.app.AlertDialog;
//import android.app.AlertDialog.Builder;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MenuInflater;

public class mainactivity extends Activity {
    /** Called when the activity is first created. */
  
	 Activity act = this;
	// @Override
    public void onCreate(Bundle savedInstanceState) {
     
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        /*
        ImageButton btn = (ImageButton)this.findViewById(R.id.imageBtn1);
        btn.setImageResource(R.drawable.ic_checker);
        btn.setOnClickListener(new OnClickListener(){
        	public void onClick(View v){
        		AlertDialog.Builder builder = new AlertDialog.Builder(act);
        		builder.setTitle("Alert Window");
        		
        		builder.setMessage("Are you sure you want to exit?");
        	    builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
        	           public void onClick(DialogInterface dialog, int id) {
        	                act.finish();
        	           }
        	       });
        	    builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
        	           public void onClick(DialogInterface dialog, int id) {
        	                dialog.cancel();
        	           }
        	       });

        		AlertDialog alert = builder.create();
        		alert.show();
        	}
        });
        
        btn = (ImageButton)this.findViewById(R.id.imageBtn2);
        btn.setImageResource(R.drawable.ic_launcher_new);
        btn.setOnClickListener(new OnClickListener(){
        	public void onClick(View v){
        		ProgressDialog dialog = ProgressDialog.show(act, "", 
                        "Loading. Please wait...", true);
        		dialog.setCancelable(true);
        		dialog.show();
        	}
        });
        
        btn = (ImageButton)this.findViewById(R.id.imageBtn3);
        btn.setImageResource(R.drawable.ic_plus);
        btn.setOnClickListener(new OnClickListener(){
        	public void onClick(View v){
        		 Intent i = new Intent(act, plusclickactivity.class);
        		 startActivity(i);     		
        	}
        });
    */
    }
    
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
    	
    	MenuInflater inflater = getMenuInflater(); //from activity
    	inflater.inflate(R.menu.option_menu, menu);
    	/*
    	super.onCreateOptionsMenu(menu);
    	menu.add(0, 1, 0, "");
    	menu.add(0, 2, 1, "");
    	menu.add(0, 3, 2, "");
    		*/	
        return true;
    }
    
    @Override
    public boolean onOptionsItemSelected(MenuItem item){
    switch(item.getItemId()) {
    case R.id.item1:
    	AlertDialog.Builder builder = new AlertDialog.Builder(act);
    	builder.setTitle("Alert Window");
    	builder.setMessage("Are you sure you want to exit?");
    	builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
    		public void onClick(DialogInterface dialog, int id) {
    			act.finish();
    	    }
        });
  	    builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                dialog.cancel();
    	    }
        });

   		AlertDialog alert = builder.create();
   		alert.show();
   		return true;
    case R.id.item2:
    	ProgressDialog dialog = ProgressDialog.show(act, "", 
                "Loading. Please wait...", true);
		dialog.setCancelable(true);
		dialog.show();
		return true;
    case R.id.item3:
    	Intent i = new Intent(act, plusclickactivity.class);
		startActivity(i); 
		return true;
    }
    return false;
    //for the rest
   
    }
    
}